home *** CD-ROM | disk | FTP | other *** search
-
- #include "parsehtm.h"
- #include <stdio.h>
- #ifndef strcasecmp
-
- int (strcasecmp)(const char *s1,const char *s2)
- {
- int returnValue = 1;
-
- if((NULL != s1)&&(NULL != s2))
- {
- char test1,test2;
-
- for(;;++s1,++s2)
- {
- test1 = tolower(*s1);
- test2 = tolower(*s2);
-
- if(test1 != test2)
- {
- returnValue =
- ((test1 < test2) ? -1:+1);
- break;
- }
- else if(test1 == '\0')
- {
- returnValue = 0;
- break;
- }
- }
- }
- else if((NULL == s1)&&(NULL == s2))
- {
- returnValue = 0;
- }
-
- return returnValue;
- }
-
- #endif
-
-
- void submitHandler(String ts,String as,String et,Dictionary td)
- {
- String value = 0;
-
- value = dict_valueForKey(td,"TYPE");
-
- if(value && value->string)
- {
- if(!strcasecmp(value->string,"submit"))
- {
- value = dict_valueForKey(td,"NAME");
-
- if(value)
- {
- string_setStringValue(value,"submit");
- }
- else
- {
- value = string_alloc(5);
- string_setStringValue(value,"submit");
- dict_setValueForKey(td, "NAME",value);
- }
-
- value = dict_valueForKey(td,"VALUE");
-
- if(value)
- {
- string_setStringValue(value,"Form was Run");
- }
- else
- {
- value = string_alloc(5);
- string_setStringValue(value,"Form was Run");
- dict_setValueForKey(td, "VALUE",value);
- }
- }
-
- }
-
- value = stringForTagDict(td);
-
- if(value)
- {
- string_setStringValue(ts,value->string);
-
- string_free(value);
- }
- }
-
- void main(int argc, char *argv[])
- {
- String output;
-
- initializeHtmlParsingLibrary();
-
- dict_setValueForKey(handlerDict,"INPUT",submitHandler);
-
- output = parseHtml("sub_c.htm");
-
- if(output && output->string)
- {
- printf("Content-type: text/html\n\n");
- fwrite(output->string,sizeof(char),strlen(output->string),stdout);
- printf("\n");
-
- string_free(output);
- }
-
- exit(0);
- }
-
-